<?
if(!defined ('U_MOD'))
{
	echo"<meta http-equiv='refresh' content='0;url=/index.php'>";
	exit;
}


if (isset($act) && is_numeric($act))
{
	if ($act==1 && isset($mid))
	{
		$queryGetModule=mysql_query("SELECT modules_key FROM ".$PortalPref."modules WHERE modules_id='".$mid."'");
		if(mysql_num_rows($queryGetModule)!=1)
			print '<p align="center">'._NO_MODULES_FOR_DEL_.'</p>';
		else
		{
			$resultGetModule=mysql_fetch_assoc($queryGetModule);
			$quryDel="DELETE FROM ".$PortalPref."modules WHERE modules_id='".$mid."'";
			$queryDelOptions="DELETE FROM ".$PortalPref."options WHERE option_mkey='".$resultGetModule['modules_key']."'";
			$queryDelNav="DELETE FROM ".$PortalPref."navigation WHERE nav_module='".$resultGetModule['modules_key']."'";
			$queryDelTitle="DELETE FROM ".$PortalPref."titles WHERE titles_mkey='".$resultGetModule['modules_key']."'";
			//$queryDelTitle
			if (mysql_query($quryDel))
			{
				print '<p align="center">'._OPERATION_SUCCESS_.'</p>';

				if(mysql_query($queryDelOptions))
					print '<p align="center">'._DEL_OPTIONS_.': '._OK_.'</p>';
				else
					print '<p align="center">'._DEL_OPTIONS_.': '._ERROR_.'</p>';

				if(mysql_query($queryDelNav))
					print '<p align="center">'._DEL_NAV_.': '._OK_.'</p>';
				else
					print '<p align="center">'._DEL_NAV_.': '._ERROR_.'</p>';

				if(mysql_query($queryDelTitle))
					print '<p align="center">'._DEL_TITLES_.': '._OK_.'</p>';
				else
					print '<p align="center">'._DEL_TITLES_.': '._ERROR_.'</p>';

				$avialable_langs = explode(",", $option['avialable_langs']);
				for($i=0; $i<count($avialable_langs); $i++)
				{
					$queryDelLangs="DELETE FROM ".$PortalPref."langs_".$avialable_langs[$i]." WHERE lang_module='".$resultGetModule['modules_key']."'";
					if (mysql_query($queryDelLangs))
						print '<p align="center">'._DEL_LANGS_.' ('.$avialable_langs[$i].'): '._OK_.'</p>';
					else
						print '<p align="center">'._DEL_LANGS_.' ('.$avialable_langs[$i].'): '._ERROR_.'</p>';
				}
			}else
				print '<p align="center">'.BAD_SQL_.'</p>';
		}
	}

	if ($act==2 && isset($mid))
	{
		if(mysql_query("UPDATE ".$PortalPref."modules SET modules_u_active='0' WHERE modules_id='".$mid."'"))
			print '<p align="center">'._OPERATION_SUCCESS_.'</p>';
		else
			print '<p align="center">'.BAD_SQL_.'</p>';
	}

	if ($act==3 && isset($mid))
	{
		if(mysql_query("UPDATE ".$PortalPref."modules SET modules_u_active='1' WHERE modules_id='".$mid."'"))
			print '<p align="center">'._OPERATION_SUCCESS_.'</p>';
		else
			print '<p align="center">'.BAD_SQL_.'</p>';
	}

	if ($act==4 && isset($mid))
	{
		if(mysql_query("UPDATE ".$PortalPref."modules SET modules_a_active='0' WHERE modules_id='".$mid."'"))
			print '<p align="center">'._OPERATION_SUCCESS_.'</p>';
		else
			print '<p align="center">'.BAD_SQL_.'</p>';
	}

	if ($act==5 && isset($mid))
	{
		if(mysql_query("UPDATE ".$PortalPref."modules SET modules_a_active='1' WHERE modules_id='".$mid."'"))
			print '<p align="center">'._OPERATION_SUCCESS_.'</p>';
		else
			print '<p align="center">'.BAD_SQL_.'</p>';
	}
}

echo"<meta http-equiv='refresh' content='0;url=/admin.php?amk=".$amk."'>";
?>